package cn.itedus.lotteryweb.controller;

import cn.itedus.lottery.rpc.activity.booth.ILotteryActivityBooth;
import cn.itedus.lottery.rpc.activity.booth.req.DrawReq;
import cn.itedus.lottery.rpc.activity.booth.res.DrawRes;
import cn.itedus.lotteryweb.common.EasyResult;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/10/6 15:42
 */
@RestController
@RequestMapping("api/activity")
public class DrawController {

    @Reference
    private ILotteryActivityBooth iLotteryActivityBooth;

    /*
     TODO : 还需要配置一个全局的异常处理器
     */

    @GetMapping("/draw/{uId}/{activityId}")
    public EasyResult draw(@PathVariable("uId")String uId, @PathVariable("activityId") Long  activityId ){
        DrawReq drawReq = new DrawReq(uId,activityId);
        EasyResult easyResult = EasyResult.buildEasyResultSuccess(iLotteryActivityBooth.doDraw(drawReq));

        return easyResult;
    }


}
